{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>房间类型名称添加</h5>
                    <div class="ibox-tools">
                        <a class="collapse-link">
                            <i class="fa fa-chevron-up"></i>
                        </a>
                    </div>
                </div>
                <div class="ibox-content">
                    <form class="form-horizontal m-t" name="add_article" id="add_article" enctype="multipart/form-data">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">房间类型名称：</label>
                            <div class="input-group col-sm-4">
                                <input id="type_name" name="type_name" type="text" class="form-control type_name">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">最低价格：</label>
                            <div class="input-group col-sm-4">
                                <input id="min_price" name="min_price" type="text" class="form-control min_price">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">酒店</label>
                            <div class="input-group col-sm-4">
                                <select class="form-control m-b" name="hotel_id" id="hotel_id">
                                    {volist name="data" id="vo"}
                                    <option value="{$vo['h_id']}">{$vo['h_name']}</option>
                                    {/volist}
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-4 col-sm-offset-3">
                                <button class="btn btn-primary btsave"  type="button"><i class="fa fa-save"></i> 保存</button>&nbsp;&nbsp;&nbsp;
                                <a class="btn btn-danger" href="javascript:history.go(-1);"><i class="fa fa-close"></i> 返回</a>
                            </div>
                        </div>
                    </form>
                </div>
            </div>

        </div>
    </div>
</div>
{include file="public/footer" /}

<script>
    $(".btsave").on('click',function () {
        $('.btn').attr('disabled',true);
        var type_name = $(".type_name").val();
        var min_price = $(".min_price").val();
        if(type_name==''){
            layer.msg("房间分类名称不能为空", {icon: 1, time: 1500, shade: 0.1}, function (index) {
            });
            $('.btn').removeAttr('disabled');
            return false;
        }
        if(min_price==''){
            layer.msg("最低价格不能为空", {icon: 1, time: 1500, shade: 0.1}, function (index) {
            });
            $('.btn').removeAttr('disabled');
            return false;
        }
        $.ajax({
            url: "{:url('assortmentadd')}",
            type: "post",
            dataType:'json',
            data: $("#add_article").serialize(),
            success: function (data) {
                if (data.code == 200) {
                    wk.success(data.msg,"{:url('hotel/assortment')}",1);
                } else if(data.code == 100){
                    $('.btn').removeAttr('disabled');
                    wk.error(data.msg,'',2);
                    return false;
                }
            }
        });
    })
</script>
</body>
</html>